home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / listings / v_01_05 / 1n05008a < prev    next >
Text File  |  1990-08-21  |  2KB  |  68 lines

  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. /* 8514/A test program - lines */
  5.  
  6. void main()
  7. {
  8. #define HOPEN 8 /* open adapter */
  9.   static struct {
  10.     short jlnth;
  11.     char qflgs,qmode,qstat;
  12.   } shopen = {3,0,0,0};
  13.  
  14. #define HQDPS 31 /* query drawing process state size */
  15.   static struct {
  16.     short jlnth,jbsiz,jssiz,jpsiz;
  17.   } shqdps = {6,0,0,0};
  18.  
  19. #define HINIT 48 /* initialize state */
  20.   static struct {
  21.     short jlnth,jbseg;
  22.   } shinit = {2,0};
  23.  
  24. #define HLINE 0 /* line at given position */
  25.   static struct {
  26.       short jlnth,jxbeg,jybeg,jxend,jyend;
  27.   } shline = {8,0,0,0,767};
  28.  
  29. #define HCLOSE 34 /* close adapter */
  30.   static struct {
  31.     short jlnth;
  32.     char qsusp;
  33.   } shclose = {1,0};
  34.  
  35.   extern int c8514(int,void *); /* AI interface */
  36.   char pqstbf[416]; /* drawing process state buffer */
  37.   int ix; /* x position */
  38.  
  39.   /* open the adapter interface */
  40.   if (c8514(HOPEN,&shopen)) {
  41.     printf("AI not loaded\n");
  42.     exit(1);
  43.   }
  44.   /* check the length of the state buffer */
  45.   c8514(HQDPS,&shqdps);
  46.   if (sizeof(pqstbf)-16 < shqdps.jbsiz) {
  47.     printf("drawing process state buffer too small\n");
  48.     exit(1);
  49.   }
  50.   /* initialize state buffer (on segment boundary) */
  51.   shinit.jbseg = ((unsigned long)pqstbf >> 16)+
  52.             (((unsigned long)pqstbf & 0xFFFF) >> 4)+1;
  53.   c8514(HINIT,&shinit);
  54.  
  55.   /* draw some lines */
  56.   for (ix = 0; ix <= 1023; ix += 3) {
  57.     shline.jxbeg = ix;
  58.     shline.jxend = 1023-ix;
  59.     c8514(HLINE,&shline);
  60.   }
  61.   /* wait for operator and quit */
  62.   c8514(-1,NULL);
  63.   getchar();
  64.   c8514(HCLOSE,&shclose);
  65.   c8514(-1,NULL);
  66.   exit(0);
  67. }
  68.